import static java.lang.Math.sqrt;

public class Sieve {
    public static int[] Sieve(int n){
        int[] A = new int[1000];
        int[] L = new int[1000];
        int j = 0;
        for (int p = 2; p <= n; p++){
            A[p] = p;
        }
        for (int p = 2; p <= sqrt(n); p++){
            if (A[p] != 0){
                j = p*p;
                while (j <= n){
                    A[j] = 0;
                    j += p;
                }
            }
        }
        int i = 0;
        for (int p =2; p <= n; p++){
            if (A[p] != 0){
                L[i] = A[p];
                i++;
            }
        }
        return L;
    }
    public static void main(String[] args) {
        int n = 100;
        int[] L = Sieve(n);
        System.out.println("0到"+n+"之间的质数为：");
        for(int a: L){
            if(a != 0)
                System.out.print(a+" ");
            else
                continue;
        }

    }
}
